<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>消费会员</title>
		<link rel="stylesheet" href="dist/css/layui.css" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<link rel="stylesheet" href="css/shouy.css" />
	</head>

	<body>
		<div class="wrap">
			<div class="sy_header clearfix">
				<div class="sy_hleft">
					<div class="sy_logobox">
						<div class="sy_logo"><img src="img/logo-ma.png"></div>
						<p id="app_name"></p>
					</div>
					<ul class="sy_nav clearfix">
						<li>
							<a href="sao_pay.html">
								<div class="iconfont icon-saomashouyin"></div>
								<p>扫码收银</p>
							</a>
						</li>
						<li>
							<a href="product_pay.html">
								<div class="iconfont icon-shangpinshouyin"></div>
								<p>商品收银</p>
							</a>
						</li>
						<li>
							<a href="house.html">
								<div class="iconfont icon-shangpinshouyin"></div>
								<p>房台收银</p>
							</a>
						</li>
						<li class="active">
							<a href="xiaof_member.html">
								<div class="iconfont icon-weibiaoti-"></div>
								<p>我的会员</p>
							</a>
						</li>
						<li>
							<a href="jingybb.html">
								<div class="iconfont icon-jingyingbaobiao"></div>
								<p>经营报表</p>
							</a>
						</li>
					</ul>
				</div>
				<div class="sy_hright">
					<div class="sy_shopbox">
						<div class="sy_simg"><img id="toux" src="" style="background-color: #FFFFFF;"></div>
						<div class="sy_sinfo">
							<p class="sy_snam">店名：<span id="sname"></span></p>
							<p>用户：<span id="user">15973240090</span></p>
							<p class="exit" onclick="exit()">退出登陆</p>
						</div>
					</div>
				</div>
			</div>

			<div class="sy_xconbox clearfix">
				<div class="sy_xftop clearfix">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">手机号</label>
							<div class="layui-input-inline">
								<input type="text" id="mobile" name="mobile" placeholder="请输入手机号" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">注册时间</label>
							<div class="layui-input-inline" style="width: 120px;">
								<input onclick='WdatePicker()' ignore type="text" name="date" placeholder="yyyy-mm-dd" id="date" autocomplete="off" class="layui-input">
							</div>
							<div class="layui-form-mid">-</div>
							<div class="layui-input-inline" style="width: 120px;">
								<input onclick='WdatePicker()' ignore type="text" name="date1" placeholder="yyyy-mm-dd" id="date1" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<button type="button" class="sy_xfbtn">搜索</button>
						</div>

					</div>
				</div>
				<div class="sy_spcenter">
					<table class="layui-table">
						<colgroup>
							<col width="170">
							<col width="130">
							<col width="90">
							<col width="180">
							<col width="140">
							<col>
						</colgroup>
						<thead>
							<tr>
								<th>姓名</th>
								<th>手机号</th>
								<th>性别</th>
								<th>鼓励金</th>
								<th>状态</th>
								<th>注册时间</th>
							</tr>
						</thead>
						<tbody id="mem_body">
						</tbody>
					</table>
					<div id="demo2" style="text-align: center;"></div>
					<ul id="biuuu_city_list"></ul> 
				</div>
			</div>
		</div>
		<script type="text/javascript" src="dist/jquery-1.11.0.min.js"></script>
		<script src="datepicker/WdatePicker.js"></script>
		<script src="dist/layui.all.js"></script>
		<script src="dist/json2.js"></script>
		<script type="text/javascript" src="js/app.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script>
		if (!document.querySelectorAll) {
    document.querySelectorAll = function (selectors) {
        var style = document.createElement('style'), elements = [], element;
        document.documentElement.firstChild.appendChild(style);
        document._qsa = [];

        style.styleSheet.cssText = selectors + '{x-qsa:expression(document._qsa && document._qsa.push(this))}';
        window.scrollBy(0, 0);
        style.parentNode.removeChild(style);

        while (document._qsa.length) {
            element = document._qsa.shift();
            element.style.removeAttribute('x-qsa');
            elements.push(element);
        }
        document._qsa = null;
        return elements;
    };
}

if (!document.querySelector) {
    document.querySelector = function (selectors) {
        var elements = document.querySelectorAll(selectors);
        return (elements.length) ? elements[0] : null;
    };
}

// 用于在IE6和IE7浏览器中，支持Element.querySelectorAll方法
var qsaWorker = (function () {
    var idAllocator = 10000;

    function qsaWorkerShim(element, selector) {
        var needsID = element.id === "";
        if (needsID) {
            ++idAllocator;
            element.id = "__qsa" + idAllocator;
        }
        try {
            return document.querySelectorAll("#" + element.id + " " + selector);
        }
        finally {
            if (needsID) {
                element.id = "";
            }
        }
    }

    function qsaWorkerWrap(element, selector) {
        return element.querySelectorAll(selector);
    }

    // Return the one this browser wants to use
    return document.createElement('div').querySelectorAll ? qsaWorkerWrap : qsaWorkerShim;
})();
		if(!getValue("agent_id")){
			location.href='login.html';
		}
			$(function() {
					set_info();
					get_mems();
			})
			
			$(".sy_xfbtn").click(function(){
				var mobile=$("#mobile").val();
				get_mems(1,mobile)
			})
			function get_mems(page,mobile){
				var laypage = layui.laypage,
				layer = layui.layer;
				var index = layer.load(1, {
				shade: [0.1, '#fff'] //0.1透明度的白色背景
				});
				$.ajax({
					url: APP.api_url + "Sy/get_members",
					data: {
						agent_id: getValue("agent_id"),
						page:page,
						mobile:mobile,
						start_time:$("#date").val(),
						end_time:$("#date1").val(),
						app_id	:APP.app_id,
						time:Date.parse( new Date())
					},
					success: function(dt) {
						layer.close(index);
						var mems = dt.list;
						if(mems) {
							var tr = "";
							for(var m in mems) {
								var name=mems[m]['user_name'];
								if(name==''||name==null){
									name='扫码支付会员';
								}
								var mobile=mems[m]['mobile'];
								if(mobile==''||mobile==null){
									mobile="未绑定";
								}
								tr += '<tr>' +
									'<td>'+name+'</td>' +
									'<td>'+mobile+'</td>' +
									'<td>'+mems[m]['sex']+'</td>' +
									'<td>'+mems[m]['score']+'</td>' +
									'<td>已认证</td>' +
									'<td>'+mems[m]['add_time']+'</td>' +
									'</tr>';
							}
							$("#mem_body").html(tr);
							var count=dt.count;
							
							laypage.render({
								elem: 'demo2',
								count: count,
								limit: 7,
								jump: function(obj,first) {
									var curr = obj.curr;
								    if(!first) {
								      get_mems1(curr);
								    }
								}
							});
						}
					}
				})

			}
			
			function get_mems1(page){
				var laypage = layui.laypage,
				layer = layui.layer;
				var index = layer.load(1, {
				shade: [0.1, '#fff'] //0.1透明度的白色背景
				});
				$.ajax({
					url: APP.api_url + "Sy/get_members",
					data: {
						agent_id: getValue("agent_id"),
						page:page,
						mobile:$("#mobile").val(),
						start_time:$("#date").val(),
						end_time:$("#date1").val(),
						app_id	:APP.app_id,
						time:Date.parse( new Date())
					},
					success: function(dt) {
						layer.close(index);
						var mems = dt.list;
						if(mems) {
							var tr = "";
							for(var m in mems) {
								var name=mems[m]['user_name'];
								if(name==''||name==null){
									name='扫码支付会员';
								}
								var mobile=mems[m]['mobile'];
								if(mobile==''||mobile==null){
									mobile="未绑定";
								}
								tr += '<tr>' +
									'<td>'+name+'</td>' +
									'<td>'+mobile+'</td>' +
									'<td>'+mems[m]['sex']+'</td>' +
									'<td>'+mems[m]['score']+'</td>' +
									'<td>已认证</td>' +
									'<td>'+mems[m]['add_time']+'</td>' +
									'</tr>';
							}
							$("#mem_body").html(tr);
						}
					}
				})

			}
		
			layui.use(['form', 'layedit', 'laydate'], function() {
				var form = layui.form,
					layer = layui.layer,
					layedit = layui.layedit,
					laydate = layui.laydate;

				//日期
				laydate.render({
					elem: '#date'
				});
				laydate.render({
					elem: '#date1'
				});

			});
		</script>

	</body>

</html>